#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <cstring>
#include <string>

using namespace std;

typedef long long int64;

const int mod = 10000;

#define iv(x) ((x) - 'a')

int main()
{
	int n;
	char line[1000];
	cin >> n;
	cin >> line;
	
	int ret = 0;
	
	int m = (n + 1) / 2;
	
	for (int i = 0; i < m; ++i)
	{
		int s = iv(line[i]);
		for (int j = i + 1; j < m; ++j)
		    s = s * 26 % mod;
		ret = (ret + s) % mod;
	}
	
	if (n & 1)
	{
		bool flag = true;
		for (int i = 0; i < m; ++i)
		{
		    if (line[m + i - 1] < line[m - i - 1]) { flag = false; break; }
		    if (line[m + i - 1] > line[m - i - 1]) break;
		}
		if (flag) ret += 1;
	} else
	{
		bool flag = true;
		for (int i = 0; i < m; ++i)
		{
		    if (line[m + i] < line[m - i - 1]) { flag = false; break; }
		    if (line[m + i] > line[m - i - 1]) break;
		}
		if (flag) ret += 1;
	}
	
	cout << ret % mod << endl;
}
